<!DOCTYPE html>
<html>
<head>
    <title>论坛 - FinData</title>
    <style>
        body {
            margin: 0;
            padding: 0;
            font-family: 'Arial', sans-serif;
            background-color: #0a0a0a;
            color: #e0e0e0;
        }
        .header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 15px 30px;
            background-color: #121212;
            border-bottom: 1px solid #333;
        }
        .logo-container {
            display: flex;
            align-items: center;
        }
        .logo {
            width: 40px;
            height: 40px;
            margin-right: 10px;
            filter: drop-shadow(0 0 5px rgba(138, 43, 226, 0.7));
            animation: pulse 2s infinite alternate;
        }
        .logo-text {
            font-size: 24px;
            font-weight: bold;
            background: linear-gradient(90deg, #8a2be2, #a855f7, #c084fc);
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
            text-shadow: 0 0 10px rgba(168, 85, 247, 0.5);
            animation: shine 3s linear infinite;
            margin-right: auto;
            padding-left: 15px;
        }
        .nav-container {
            display: flex;
            gap: 20px;
        }
        .nav-item {
            position: relative;
            padding: 10px 20px;
            background: linear-gradient(145deg, #1e1e1e, #2a2a2a);
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.3s ease;
            color: #e0e0e0;
            text-decoration: none;
            overflow: hidden;
            z-index: 1;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }
        .nav-item::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(45deg, #8a2be2, #00bfff);
            z-index: -1;
            opacity: 0;
            transition: opacity 0.3s ease;
        }
        .nav-item:hover {
            transform: translateY(-3px);
            box-shadow: 0 6px 12px rgba(138, 43, 226, 0.3);
            color: white;
        }
        .nav-item:hover::before {
            opacity: 1;
        }
        .nav-item::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 50%;
            width: 0;
            height: 3px;
            background: #4CAF50;
            transition: all 0.3s ease;
        }
        .nav-item:hover::after {
            width: 70%;
            left: 15%;
        }
        
        /* 论坛内容样式 */
        .container {
            display: flex;
            padding: 20px;
            max-width: 1200px;
            margin: 0 auto;
        }
        .main-content {
            flex: 3;
            margin-right: 20px;
        }
        .sidebar {
            flex: 1;
            margin-top: 200px; /* 添加顶部外边距，让侧边栏内容向下移动 */
        }
        .forum-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            flex-wrap: wrap;
        }
        .forum-title {
            font-size: 24px;
            font-weight: bold;
            color: #e0e0e0;
        }
        .create-post-btn {
            padding: 12px 24px;
            background: linear-gradient(45deg, #8a2be2, #a855f7);
            color: white;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.3s ease;
            font-weight: bold;
            position: relative;
            overflow: hidden;
            box-shadow: 0 4px 15px rgba(138, 43, 226, 0.3);
            z-index: 1;
            display: flex;
            align-items: center;
        }
        .create-post-btn i {
            margin-right: 8px;
        }
        .create-post-btn::before {
            content: '';
            position: absolute;
            top: 0;
            left: -100%;
            width: 100%;
            height: 100%;
            background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
            transition: all 0.5s ease;
            z-index: -1;
        }
        .create-post-btn:hover {
            transform: translateY(-3px);
            box-shadow: 0 7px 20px rgba(138, 43, 226, 0.5);
        }
        .create-post-btn:hover::before {
            left: 100%;
        }
        .create-post-btn:active {
            transform: translateY(1px);
        }
        .post-list {
            background-color: #121212;
            border-radius: 10px;
            padding: 20px;
        }
        .post-item {
            border-bottom: 1px solid #333;
            padding: 20px;
            transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
            position: relative;
            animation: fadeIn 0.5s ease forwards;
            animation-delay: calc(0.1s * var(--index, 0));
            opacity: 0;
            margin-bottom: 5px;
            border-radius: 8px;
        }
        .post-item:last-child {
            border-bottom: none;
        }
        .post-item:hover {
            background-color: #1a1a1a;
            transform: translateX(5px) scale(1.01);
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
            z-index: 2;
            border-left: 3px solid #8a2be2;
        }
        .post-title {
            font-size: 18px;
            margin-bottom: 10px;
            color: #e0e0e0;
            text-decoration: none;
        }
        .post-title a {
            color: #e0e0e0;
            text-decoration: none;
            transition: color 0.3s;
        }
        .post-title a:hover {
            color: #8a2be2;
        }
        .post-meta {
            display: flex;
            font-size: 12px;
            color: #888;
            margin-bottom: 10px;
        }
        .post-author, .post-date, .post-views {
            margin-right: 15px;
        }
        .post-stats {
            display: flex;
            align-items: center;
        }
        .post-likes, .post-comments {
            display: flex;
            align-items: center;
            margin-right: 15px;
            color: #888;
        }
        .post-likes i, .post-comments i {
            margin-right: 5px;
            font-size: 14px;
        }
        .post-preview {
            color: #aaa;
            margin-bottom: 10px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
        }
        
        /* 侧边栏样式 */
        .sidebar-section {
            background: linear-gradient(145deg, #141414, #1e1e1e);
            border-radius: 12px;
            padding: 25px;
            margin-bottom: 30px;
            box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
            transition: all 0.3s ease;
            position: relative;
            overflow: hidden;
            border-left: 4px solid transparent;
        }
        
        .sidebar-section:hover {
            transform: translateY(-5px);
            box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
        }
        
        .hot-posts-section {
            border-left-color: #ff6b6b;
        }
        
        .stats-section {
            border-left-color: #4CAF50;
        }
        
        .hot-tags-section {
            border-left-color: #8a2be2;
        }
        
        .sidebar-section::before {
            content: '';
            position: absolute;
            top: 0;
            right: 0;
            width: 100px;
            height: 100px;
            background: radial-gradient(circle, rgba(255, 255, 255, 0.05) 0%, transparent 70%);
            border-radius: 50%;
            opacity: 0.5;
        }
        
        .sidebar-title {
            font-size: 18px;
            font-weight: bold;
            margin-bottom: 20px;
            padding-bottom: 12px;
            position: relative;
            background: linear-gradient(90deg, #e0e0e0, #a0a0a0);
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
            display: flex;
            align-items: center;
            border-bottom: 1px solid #333;
        }
        
        .sidebar-title i {
            margin-right: 10px;
            font-size: 20px;
            background: inherit;
            -webkit-background-clip: text;
            background-clip: text;
            color: white;
        }
        
        .hot-posts-section .sidebar-title i {
            color: #ff6b6b;
        }
        
        .stats-section .sidebar-title i {
            color: #4CAF50;
        }
        
        .sidebar-title::after {
            content: '';
            position: absolute;
            bottom: -1px;
            left: 0;
            width: 50px;
            height: 3px;
            background: linear-gradient(90deg, #8a2be2, #00bfff);
            border-radius: 3px;
            animation: borderGlow 3s infinite;
        }
        
        .hot-posts-list {
            display: flex;
            flex-direction: column;
            gap: 10px;
        }
        
        .hot-post-item {
            padding: 15px;
            border-bottom: 1px solid #222;
            transition: all 0.3s ease;
            border-radius: 8px;
            position: relative;
            overflow: hidden;
        }
        
        .hot-post-item:last-child {
            border-bottom: none;
        }
        
        .hot-post-item::before {
            content: '';
            position: absolute;
            top: 0;
            left: -100%;
            width: 100%;
            height: 100%;
            background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
            transition: all 0.5s ease;
        }
        
        .hot-post-item:hover {
            background-color: rgba(138, 43, 226, 0.1);
            transform: translateX(5px);
            padding-left: 20px;
        }
        
        .hot-post-item:hover::before {
            left: 100%;
        }
        
        .hot-post-title {
            font-size: 14px;
            margin-bottom: 8px;
            line-height: 1.4;
        }
        
        .hot-post-title a {
            color: #e0e0e0;
            text-decoration: none;
            transition: color 0.3s;
        }
        
        .hot-post-title a:hover {
            color: #8a2be2;
        }
        
        .hot-post-meta {
            display: flex;
            font-size: 12px;
            color: #888;
        }
        
        .hot-post-likes, .hot-post-comments {
            margin-right: 12px;
            display: flex;
            align-items: center;
        }
        
        .hot-post-likes i {
            color: #ff6b6b;
            margin-right: 5px;
            font-size: 12px;
        }
        
        .hot-post-comments i {
            color: #4CAF50;
            margin-right: 5px;
            font-size: 12px;
        }
        
        /* 分页样式 */
        .pagination {
            display: flex;
            justify-content: center;
            margin-top: 20px;
        }
        .page-item {
            margin: 0 5px;
        }
        .page-link {
            display: block;
            padding: 8px 12px;
            background-color: #1e1e1e;
            color: #e0e0e0;
            border-radius: 5px;
            text-decoration: none;
            transition: all 0.3s;
        }
        .page-link:hover {
            background-color: #8a2be2;
        }
        .page-item.active .page-link {
            background-color: #8a2be2;
        }
        .page-item.disabled .page-link {
            background-color: #1a1a1a;
            color: #555;
            cursor: not-allowed;
        }
        
        /* 动画 */
        @keyframes pulse {
            0% {
                transform: scale(1);
                opacity: 0.8;
            }
            100% {
                transform: scale(1.1);
                opacity: 1;
                filter: drop-shadow(0 0 10px rgba(138, 43, 226, 0.9));
            }
        }
        @keyframes shine {
            to {
                background-position: 200% center;
            }
        }
        
        /* 新增动效 */
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(20px); }
            to { opacity: 1; transform: translateY(0); }
        }
        
        @keyframes glowPulse {
            0% { box-shadow: 0 0 5px rgba(138, 43, 226, 0.3); }
            50% { box-shadow: 0 0 15px rgba(138, 43, 226, 0.7); }
            100% { box-shadow: 0 0 5px rgba(138, 43, 226, 0.3); }
        }
        
        @keyframes borderGlow {
            0% { border-color: rgba(138, 43, 226, 0.3); }
            50% { border-color: rgba(138, 43, 226, 0.8); }
            100% { border-color: rgba(138, 43, 226, 0.3); }
        }
        
        /* 登录提示模态框 */
        .modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.7);
            z-index: 1000;
            justify-content: center;
            align-items: center;
        }
        .modal-content {
            background-color: #1a1a1a;
            border-radius: 10px;
            padding: 30px;
            width: 400px;
            text-align: center;
            box-shadow: 0 0 20px rgba(138, 43, 226, 0.5);
            position: relative;
        }
        .modal-icon {
            margin-bottom: 20px;
        }
        .modal-title {
            font-size: 20px;
            margin-bottom: 10px;
            color: #e0e0e0;
        }
        .modal-message {
            color: #aaa;
            margin-bottom: 20px;
        }
        .modal-buttons {
            display: flex;
            justify-content: center;
            gap: 10px;
        }
        .modal-btn {
            padding: 10px 20px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            transition: all 0.3s;
            font-weight: bold;
            background: linear-gradient(45deg, #8a2be2, #a855f7);
            color: white;
        }
        .modal-btn:hover {
            background: linear-gradient(45deg, #7928a1, #9333ea);
            transform: translateY(-2px);
        }
        .modal-btn:active {
            transform: scale(0.95);
        }
        .close {
            position: absolute;
            top: 10px;
            right: 15px;
            font-size: 24px;
            color: #aaa;
            cursor: pointer;
            transition: all 0.3s;
        }
        .close:hover {
            color: white;
        }
        .close-btn {
            position: absolute;
            top: 10px;
            right: 15px;
            font-size: 24px;
            color: #aaa;
            cursor: pointer;
            transition: all 0.3s;
        }
        .close-btn:hover {
            color: white;
        }
        
        /* 搜索提示模态框特殊样式 */
        #searchAlertModal .modal-content {
            background: linear-gradient(145deg, #1a1a1a, #232323);
            border: 1px solid #333;
            box-shadow: 0 0 25px rgba(243, 156, 18, 0.3);
            animation: fadeIn 0.3s ease-out;
        }
        
        #searchAlertModal h2 {
            color: #e0e0e0;
            font-size: 22px;
            margin-bottom: 20px;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        
        #searchAlertModal h2 i {
            margin-right: 10px;
            font-size: 24px;
        }
        
        #searchAlertModal p {
            color: #aaa;
            font-size: 16px;
            margin-bottom: 25px;
        }
        
        #searchAlertModal .modal-btn {
            background: linear-gradient(45deg, #f39c12, #f1c40f);
            padding: 12px 30px;
            font-size: 16px;
            border-radius: 8px;
            color: #222;
            font-weight: bold;
            box-shadow: 0 4px 10px rgba(243, 156, 18, 0.3);
        }
        
        #searchAlertModal .modal-btn:hover {
            background: linear-gradient(45deg, #e67e22, #f39c12);
            transform: translateY(-3px);
            box-shadow: 0 6px 15px rgba(243, 156, 18, 0.4);
        }
        
        #searchAlertModal .modal-btn:active {
            transform: translateY(-1px);
        }
        
        /* 搜索框样式 */
        .search-container {
            background: linear-gradient(145deg, #121212, #1a1a1a);
            padding: 20px 0;
            display: flex;
            justify-content: center;
            margin-bottom: 20px;
            border-bottom: 1px solid #333;
            display: none; /* 隐藏顶部搜索框 */
        }
        
        .search-box {
            display: flex;
            width: 80%;
            max-width: 800px;
            position: relative;
        }
        
        .search-input {
            flex: 1;
            padding: 10px 15px;
            background-color: #1a1a1a;
            border: 1px solid #333;
            border-radius: 8px 0 0 8px;
            color: #e0e0e0;
            font-size: 16px;
            transition: all 0.3s ease;
        }
        .search-input:focus {
            outline: none;
            border-color: #8a2be2;
            box-shadow: 0 0 10px rgba(138, 43, 226, 0.3);
        }
        .search-btn {
            padding: 10px 20px;
            background: linear-gradient(45deg, #8a2be2, #a855f7);
            border: none;
            border-radius: 0 8px 8px 0;
            color: white;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.3s ease;
        }
        .search-btn:hover {
            background: linear-gradient(45deg, #7928a1, #9333ea);
            transform: translateY(-2px);
        }
        
        /* 热门标签样式 */
        .hot-tags-section {
            margin-top: 25px;
            animation: fadeIn 0.8s ease;
        }
        
        .hot-tags-section .sidebar-title i {
            color: #ff6b6b;
            margin-right: 8px;
        }
        
        .tag-list {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            margin-top: 15px;
        }
        
        .hot-tag {
            padding: 8px 15px;
            background: linear-gradient(145deg, rgba(138, 43, 226, 0.1), rgba(138, 43, 226, 0.2));
            border: 1px solid rgba(138, 43, 226, 0.3);
            border-radius: 20px;
            font-size: 13px;
            color: #a855f7;
            cursor: pointer;
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
            position: relative;
            overflow: hidden;
        }
        
        .hot-tag::before {
            content: '';
            position: absolute;
            top: 0;
            left: -100%;
            width: 100%;
            height: 100%;
            background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
            transition: all 0.5s ease;
        }
        
        .hot-tag:hover {
            background: linear-gradient(145deg, rgba(138, 43, 226, 0.2), rgba(138, 43, 226, 0.3));
            transform: translateY(-3px) scale(1.05);
            box-shadow: 0 5px 15px rgba(138, 43, 226, 0.3);
        }
        
        .hot-tag:hover::before {
            left: 100%;
        }
        
        .tag-count {
            background-color: rgba(138, 43, 226, 0.4);
            color: #fff;
            font-size: 11px;
            font-weight: bold;
            padding: 3px 8px;
            border-radius: 12px;
            margin-left: 8px;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
            display: inline-flex;
            align-items: center;
            justify-content: center;
            min-width: 20px;
        }
        
        /* 搜索结果样式 */
        .search-results {
            background-color: #121212;
            border-radius: 10px;
            padding: 20px;
            margin-bottom: 20px;
            animation: fadeIn 0.5s ease;
        }
        .search-results-title {
            font-size: 20px;
            font-weight: bold;
            margin-bottom: 20px;
            padding-bottom: 10px;
            border-bottom: 1px solid #333;
            color: #e0e0e0;
        }
        .search-section {
            margin-bottom: 30px;
        }
        .search-section-title {
            font-size: 16px;
            font-weight: bold;
            margin-bottom: 15px;
            color: #8a2be2;
            display: flex;
            align-items: center;
        }
        .search-section-title::before {
            content: '';
            display: inline-block;
            width: 4px;
            height: 16px;
            background-color: #8a2be2;
            margin-right: 10px;
            border-radius: 2px;
        }
        .no-results {
            color: #888;
            font-style: italic;
            text-align: center;
            padding: 20px 0;
        }
        .back-btn {
            padding: 10px 20px;
            background: linear-gradient(145deg, #1e1e1e, #2a2a2a);
            color: #e0e0e0;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            margin-top: 20px;
        }
        .back-btn i {
            margin-right: 8px;
        }
        .back-btn:hover {
            background: linear-gradient(145deg, #252525, #333333);
            transform: translateY(-3px);
        }
        .search-highlight {
            background-color: rgba(138, 43, 226, 0.3);
            padding: 0 2px;
            border-radius: 2px;
        }
        
        /* 搜索框样式优化 */
        .forum-search {
            display: flex;
            width: 100%;
            max-width: 400px;
            position: relative;
            margin: 15px 0;
        }
        .search-input {
            flex: 1;
            padding: 12px 15px;
            background-color: #1a1a1a;
            border: 1px solid #333;
            border-radius: 8px 0 0 8px;
            color: #e0e0e0;
            font-size: 15px;
            transition: all 0.3s ease;
            box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2);
        }
        .search-input:focus {
            outline: none;
            border-color: #8a2be2;
            box-shadow: 0 0 10px rgba(138, 43, 226, 0.3), inset 0 2px 5px rgba(0, 0, 0, 0.2);
        }
        .search-btn {
            padding: 12px 20px;
            background: linear-gradient(45deg, #8a2be2, #a855f7);
            border: none;
            border-radius: 0 8px 8px 0;
            color: white;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 0 4px 10px rgba(138, 43, 226, 0.3);
            display: flex;
            align-items: center;
        }
        .search-btn i {
            margin-right: 5px;
        }
        .search-btn:hover {
            background: linear-gradient(45deg, #7928a1, #9333ea);
            transform: translateY(-2px);
            box-shadow: 0 6px 15px rgba(138, 43, 226, 0.5);
        }
        .search-btn:active {
            transform: translateY(1px);
        }
        
        /* 论坛统计样式 */
        .forum-stats {
            display: flex;
            flex-direction: column;
            gap: 10px;
        }
        
        .stat-item {
            display: flex;
            justify-content: space-between;
            padding: 10px 0;
            border-bottom: 1px solid #333;
        }
        
        .stat-item:last-child {
            border-bottom: none;
        }
        
        .stat-label {
            color: #888;
        }
        
        .stat-value {
            color: #e0e0e0;
            font-weight: bold;
        }
        
        /* 举报模态框样式 */
        .report-options {
            display: flex;
            flex-direction: column;
            gap: 10px;
            margin: 20px 0;
            text-align: left;
        }
        
        .report-option {
            display: flex;
            align-items: center;
            cursor: pointer;
            transition: all 0.3s ease;
            padding: 10px;
            border-radius: 5px;
        }
        
        .report-option:hover {
            background-color: #222;
        }
        
        .report-option input {
            margin-right: 10px;
        }
        
        .report-detail {
            width: 100%;
            height: 100px;
            padding: 10px;
            margin-bottom: 20px;
            border: 1px solid #333;
            border-radius: 5px;
            background-color: #1a1a1a;
            color: #e0e0e0;
            resize: vertical;
        }
        
        .report-detail:focus {
            outline: none;
            border-color: #8a2be2;
        }
        
        .report-btn {
            background: linear-gradient(145deg, #ff6b6b, #e53935);
            color: white;
        }
        
        .report-btn:hover {
            background: linear-gradient(145deg, #e53935, #d32f2f);
        }
        
        /* 排序选项样式 */
        .sort-options {
            display: flex;
            margin: 15px 0;
            background: linear-gradient(145deg, #121212, #1a1a1a);
            border-radius: 8px;
            padding: 5px;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
        }
        .sort-option {
            padding: 8px 15px;
            cursor: pointer;
            border-radius: 6px;
            transition: all 0.3s ease;
            margin: 0 2px;
            font-size: 14px;
            display: flex;
            align-items: center;
        }
        .sort-option i {
            margin-right: 5px;
            font-size: 12px;
        }
        .sort-option:hover {
            background-color: rgba(138, 43, 226, 0.3);
        }
        .sort-option.active {
            background-color: #8a2be2;
            color: white;
        }
        
        /* 免责声明和版权信息样式 */
        .disclaimer-container {
            background-color: rgba(18, 18, 18, 0.8);
            border-radius: 8px;
            padding: 15px;
            margin: 30px auto;
            max-width: 1200px;
            border-top: 1px solid #333;
        }
        
        .disclaimer-text {
            font-size: 12px;
            color: #888;
            text-align: center;
            line-height: 1.5;
            margin-bottom: 10px;
        }
        
        .copyright {
            font-size: 12px;
            color: #666;
            text-align: center;
            margin-top: 10px;
        }
        
        /* 禁言提示模态框特有样式 */
        #muteModal .modal-content {
            background: linear-gradient(145deg, #1a1a1a, #232323);
            border-left: 5px solid #dc3545;
            box-shadow: 0 0 30px rgba(220, 53, 69, 0.3);
            max-width: 450px;
            padding: 35px;
        }
        
        #muteModal h2 {
            color: #dc3545;
            font-size: 24px;
            margin-bottom: 20px;
            text-shadow: 0 0 10px rgba(220, 53, 69, 0.2);
            display: flex;
            align-items: center;
        }
        
        #muteModal h2::before {
            content: '\f05e';
            font-family: 'Font Awesome 5 Free';
            font-weight: 900;
            margin-right: 10px;
            font-size: 24px;
        }
        
        #muteModal #muteMessage {
            color: #e0e0e0;
            font-size: 16px;
            margin-bottom: 20px;
            line-height: 1.5;
            text-align: left;
        }
        
        #muteModal p:last-of-type {
            background: rgba(220, 53, 69, 0.1);
            padding: 15px;
            border-radius: 8px;
            text-align: left;
            margin-bottom: 25px;
            border-left: 3px solid rgba(220, 53, 69, 0.5);
        }
        
        #muteModal strong {
            color: #aaa;
        }
        
        #muteModal #muteReason {
            color: #e0e0e0;
            font-weight: normal;
        }
        
        #muteModal .modal-btn {
            background: linear-gradient(45deg, #dc3545, #c82333);
            padding: 12px 30px;
            font-size: 16px;
            border-radius: 8px;
            color: white;
            font-weight: bold;
            box-shadow: 0 4px 10px rgba(220, 53, 69, 0.3);
            margin-top: 10px;
            display: block;
            width: 100%;
        }
        
        #muteModal .modal-btn:hover {
            background: linear-gradient(45deg, #c82333, #bd2130);
            transform: translateY(-3px);
            box-shadow: 0 6px 15px rgba(220, 53, 69, 0.4);
        }
    </style>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
</head>
<body>
    <div class="header">
        <div class="logo-container">
            <svg class="logo" viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg">
                <path d="M20 0 L40 20 L20 40 L0 20 Z" fill="#8a2be2"/>
                <path d="M10 10 L30 10 L30 30 L10 30 Z" fill="#00bfff"/>
                <path d="M15 15 L25 15 L25 25 L15 25 Z" fill="#4CAF50"/>
            </svg>
            <div class="logo-text">FinData</div>
        </div>
        
        <div class="nav-container">
            <a class="nav-item" href="/blank" id="homeNav">首页</a>
            <a class="nav-item" href="/favorites" id="favoritesNav">自选</a>
            <a class="nav-item" href="/data" id="dataNav">数据</a>
            <a class="nav-item" href="javascript:void(0)" onclick="checkLoginForBacktest()" id="backtestNav">回测</a>
            <a class="nav-item active" href="/forum" id="forumNav">论坛</a>
            <a class="nav-item" href="/login" id="loginNav">登录</a>
            <a class="nav-item" style="display: none;" href="/dashboard" id="dashboardNav">个人中心</a>
        </div>
    </div>

    <div class="container">
        <div class="main-content">
            <div class="forum-header">
                <div class="forum-title">
                    <h1>FinData论坛</h1>
                    <p>分享金融见解，交流投资心得</p>
                </div>
                
                <div class="forum-search">
                    <input type="text" class="search-input" id="searchInput" placeholder="搜索帖子...">
                    <button class="search-btn" id="searchBtn" onclick="performSearch()"><i class="fas fa-search"></i> 搜索</button>
                </div>
                
                <button class="create-post-btn" id="createPostBtn">
                    <i class="fas fa-plus"></i> 发布新帖
                </button>
            </div>
            
            <div class="sort-options" id="sortOptions">
                <div class="sort-option active" data-sort="newest">
                    <i class="fas fa-clock"></i> 最新
                </div>
                <div class="sort-option" data-sort="likes">
                    <i class="fas fa-heart"></i> 点赞数
                </div>
                <div class="sort-option" data-sort="comments">
                    <i class="fas fa-comment"></i> 评论数
                </div>
                <div class="sort-option" data-sort="views">
                    <i class="fas fa-eye"></i> 浏览量
                </div>
                <div class="sort-option" data-sort="hot">
                    <i class="fas fa-fire"></i> 热度
                </div>
            </div>
            

            
            <!-- 搜索结果区域，默认隐藏 -->
            <div class="search-results" id="searchResults" style="display: none;">
                <div class="search-results-title">搜索结果: <span id="searchKeyword"></span></div>
                
                <div class="search-section">
                    <div class="search-section-title">标题匹配</div>
                    <div class="post-list" id="titleSearchResults"></div>
                </div>
                
                <div class="search-section">
                    <div class="search-section-title">标签匹配</div>
                    <div class="post-list" id="tagSearchResults"></div>
                </div>
                
                <div class="search-section">
                    <div class="search-section-title">内容匹配</div>
                    <div class="post-list" id="contentSearchResults"></div>
                </div>
                
                <button class="back-btn" id="backToListBtn"><i class="fas fa-arrow-left"></i> 返回论坛列表</button>
            </div>
            
            <div class="post-list" id="postList">
                <!-- 帖子列表将通过JavaScript动态加载 -->
                <div class="post-item">
                    <div class="post-title"><a href="/forum/post/1">加载中...</a></div>
                    <div class="post-meta">
                        <div class="post-author"><i class="fas fa-user"></i> 加载中...</div>
                        <div class="post-date"><i class="far fa-clock"></i> 加载中...</div>
                        <div class="post-views"><i class="fas fa-eye"></i> 加载中...</div>
                    </div>
                    <div class="post-preview">加载中...</div>
                    <div class="post-actions">
                        <div class="post-stats">
                            <div class="post-likes"><i class="far fa-heart"></i> 加载中...</div>
                            <div class="post-comments"><i class="far fa-comment"></i> 加载中...</div>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="pagination" id="pagination">
                <!-- 分页将通过JavaScript动态加载 -->
            </div>
        </div>
        
        <div class="sidebar">
            <div class="sidebar-section hot-posts-section">
                <div class="sidebar-title">
                    <i class="fas fa-fire"></i> 热门帖子Top5
                </div>
                <div id="hotPosts" class="hot-posts-list">
                    <!-- 热门帖子将通过JavaScript动态加载 -->
                </div>
            </div>
            
            <div class="sidebar-section stats-section">
                <div class="sidebar-title">
                    <i class="fas fa-chart-bar"></i> 论坛统计
                </div>
                <div class="forum-stats">
                    <div class="stat-item">
                        <div class="stat-label">总帖数</div>
                        <div class="stat-value" id="totalPosts">--</div>
                    </div>
                    <div class="stat-item">
                        <div class="stat-label">用户数</div>
                        <div class="stat-value" id="totalUsers">--</div>
                    </div>
                    <div class="stat-item">
                        <div class="stat-label">今日新帖</div>
                        <div class="stat-value" id="todayPosts">--</div>
                    </div>
                </div>
            </div>
            
            <div class="sidebar-section hot-tags-section" id="hotTagsContainer">
                <div class="sidebar-title">
                    <i class="fas fa-tags"></i> 热门标签
                </div>
                <div class="tag-list" id="hotTagsList">
                    <div class="hot-tag">加载中...</div>
                </div>
            </div>
        </div>
    </div>
    
    <!-- 登录提示模态框 -->
    <div id="loginModal" class="modal" style="display: none;">
        <div class="modal-content">
            <span class="close" onclick="closeModal()">&times;</span>
            <h2>需要登录</h2>
            <p id="modalMessage">请先登录后再进行操作</p>
            <button class="modal-btn" onclick="goToLogin()">去登录</button>
        </div>
    </div>
    
    <!-- 禁言提示模态框 -->
    <div id="muteModal" class="modal" style="display: none;">
        <div class="modal-content">
            <span class="close" onclick="closeMuteModal()">&times;</span>
            <h2>账户已被禁言</h2>
            <p id="muteMessage">您的账户已被禁言，无法进行此操作。</p>
            <p><strong>禁言原因:</strong> <span id="muteReason">违反平台规则</span></p>
            <button class="modal-btn" onclick="closeMuteModal()">我知道了</button>
        </div>
    </div>

    <!-- 举报模态框 -->
    <div id="reportModal" class="modal">
        <div class="modal-content">
            <span class="close-btn" onclick="closeReportModal()">&times;</span>
            <div class="modal-icon">
                <i class="fas fa-flag" style="color: #ff6b6b; font-size: 48px;"></i>
            </div>
            <h3 class="modal-title">举报帖子</h3>
            <p class="modal-message">请选择举报原因：</p>
            <div class="report-options">
                <label class="report-option">
                    <input type="radio" name="reportReason" value="spam"> 垃圾广告
                </label>
                <label class="report-option">
                    <input type="radio" name="reportReason" value="offensive"> 冒犯性内容
                </label>
                <label class="report-option">
                    <input type="radio" name="reportReason" value="inappropriate"> 不当内容
                </label>
                <label class="report-option">
                    <input type="radio" name="reportReason" value="other"> 其他
                </label>
            </div>
            <textarea id="reportDetail" placeholder="补充说明（选填）..." class="report-detail"></textarea>
            <div class="modal-buttons">
                <button class="modal-btn cancel-btn" onclick="closeReportModal()">取消</button>
                <button class="modal-btn report-btn" id="submitReportBtn">提交举报</button>
            </div>
        </div>
    </div>

    <!-- 添加搜索提示模态框 -->
    <div id="searchAlertModal" class="modal" style="display: none;">
        <div class="modal-content">
            <span class="close" onclick="closeSearchAlertModal()">&times;</span>
            <h2><i class="fas fa-exclamation-circle" style="color: #f39c12;"></i> 搜索提示</h2>
            <p id="searchAlertMessage">请输入搜索关键词</p>
            <button class="modal-btn" onclick="closeSearchAlertModal()">确定</button>
        </div>
    </div>

    <script>
        // 检查用户是否已登录
        let isLoggedIn = false;
        let userId = null;
        let username = null;
        let currentPage = 1;
        let totalPages = 1;
        let isSearchMode = false;
        let currentPostId = null;
        
        // 页面加载完成后执行
        document.addEventListener('DOMContentLoaded', function() {
            checkLoginStatus();
            
            // 检查URL中是否有tag参数
            const urlParams = new URLSearchParams(window.location.search);
            const tagParam = urlParams.get('tag');
            if (tagParam) {
                // 如果有tag参数，自动执行标签搜索
                searchByTag(decodeURIComponent(tagParam));
            } else {
                // 否则加载普通帖子列表
                loadPosts(currentPage);
            }
            
            loadHotTags();
            loadHotPosts();
            loadForumStats();
            
            // 初始化禁言模态框关闭按钮事件
            const closeMuteBtn = document.querySelector('#muteModal .modal-btn');
            if (closeMuteBtn) {
                closeMuteBtn.addEventListener('click', closeMuteModal);
            }
            
            // 绑定搜索按钮点击事件
            try {
                const searchBtn = document.getElementById('searchBtn');
                console.log('搜索按钮元素:', searchBtn);
                if (searchBtn) {
                    searchBtn.addEventListener('click', function() {
                        console.log('搜索按钮被点击');
                        performSearch();
                    });
                } else {
                    console.error('未找到搜索按钮元素');
                }
                
                const searchInput = document.getElementById('searchInput');
                console.log('搜索输入框元素:', searchInput);
                if (searchInput) {
                    searchInput.addEventListener('keydown', function(e) {
                        if (e.key === 'Enter') {
                            console.log('搜索输入框回车键被按下');
                            performSearch();
                        }
                    });
                } else {
                    console.error('未找到搜索输入框元素');
                }
            } catch (error) {
                console.error('绑定搜索事件时出错:', error);
            }
            
            // 绑定返回列表按钮点击事件
            document.getElementById('backToListBtn').addEventListener('click', backToList);
            
            // 绑定发布新帖按钮点击事件
            document.getElementById('createPostBtn').addEventListener('click', function(e) {
                e.preventDefault(); // 阻止默认跳转行为
                createPost();
            });
            
            // 注册举报按钮事件
            document.getElementById('submitReportBtn').addEventListener('click', submitReport);
            
            // 绑定排序选项点击事件
            const sortOptions = document.querySelectorAll('.sort-option');
            sortOptions.forEach(option => {
                option.addEventListener('click', function() {
                    // 移除所有active类
                    sortOptions.forEach(opt => opt.classList.remove('active'));
                    // 添加active类到当前选中的选项
                    this.classList.add('active');
                    // 获取排序方式
                    const sortBy = this.getAttribute('data-sort');
                    // 重新加载帖子
                    loadPosts(1, sortBy);
                });
            });
        });
        
        // 检查用户登录状态
        function checkLoginStatus() {
            fetch('/api/user-info')
                .then(response => {
                    if (response.status === 200) {
                        isLoggedIn = true;
                        return response.json();
                    } else {
                        isLoggedIn = false;
                        throw new Error('未登录');
                    }
                })
                .then(data => {
                    userId = data.UserId;
                    username = data.username;
                    
                    // 更新导航栏
                    document.getElementById('loginNav').style.display = 'none';
                    document.getElementById('dashboardNav').style.display = 'block';
                })
                .catch(error => {
                    console.log('未登录或获取用户信息失败:', error);
                });
        }
        
        // 加载帖子列表
        function loadPosts(page, sortBy = 'newest') {
            fetch(`/api/forum/posts?page=${page}&sortBy=${sortBy}`)
                .then(response => response.json())
                .then(data => {
                    const postList = document.getElementById('postList');
                    postList.innerHTML = '';
                    
                    if (data.posts.length === 0) {
                        postList.innerHTML = '<div class="post-item"><div class="post-title">暂无帖子</div></div>';
                        return;
                    }
                    
                    data.posts.forEach((post, index) => {
                        const date = new Date(post.createdAt);
                        const formattedDate = `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, '0')}-${date.getDate().toString().padStart(2, '0')} ${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')}`;
                        
                        const postItem = document.createElement('div');
                        postItem.className = 'post-item';
                        postItem.style.setProperty('--index', index);
                        
                        postItem.innerHTML = `
                            <div class="post-title"><a href="/forum/post/${post.id}">${post.title}</a></div>
                            <div class="post-meta">
                                <div class="post-author"><i class="fas fa-user"></i> ${post.username || '匿名用户'}</div>
                                <div class="post-date"><i class="far fa-clock"></i> ${formattedDate}</div>
                                <div class="post-views"><i class="fas fa-eye"></i> ${post.viewCount}</div>
                            </div>
                            <div class="post-preview">${post.content}</div>
                            <div class="post-actions">
                                <div class="post-stats">
                                    <div class="post-likes"><i class="far fa-heart"></i> ${post.likeCount}</div>
                                    <div class="post-comments"><i class="far fa-comment"></i> ${post.commentCount}</div>
                                </div>
                            </div>
                        `;
                        postList.appendChild(postItem);
                    });
                    
                    // 创建分页
                    renderPagination(data.pagination);
                })
                .catch(error => {
                    console.error('加载帖子列表失败:', error);
                    document.getElementById('postList').innerHTML = '<div class="post-item"><div class="post-title">加载失败，请稍后再试</div></div>';
                });
        }
        
        // 加载热门帖子
        function loadHotPosts() {
            fetch('/api/forum/hot-posts')
                .then(response => response.json())
                .then(posts => {
                    const hotPostsContainer = document.getElementById('hotPosts');
                    hotPostsContainer.innerHTML = '';
                    
                    if (posts.length === 0) {
                        hotPostsContainer.innerHTML = '<div class="hot-post-item">暂无热门帖子</div>';
                        return;
                    }
                    
                    posts.forEach(post => {
                        const hotPostItem = document.createElement('div');
                        hotPostItem.className = 'hot-post-item';
                        hotPostItem.innerHTML = `
                            <div class="hot-post-title"><a href="/forum/post/${post.id}">${post.title}</a></div>
                            <div class="hot-post-meta">
                                <div class="hot-post-likes"><i class="fas fa-heart"></i> ${post.likeCount}</div>
                                <div class="hot-post-comments"><i class="fas fa-comment"></i> ${post.commentCount}</div>
                            </div>
                        `;
                        hotPostsContainer.appendChild(hotPostItem);
                    });
                })
                .catch(error => {
                    console.error('加载热门帖子失败:', error);
                    document.getElementById('hotPosts').innerHTML = '<div class="hot-post-item">加载失败，请稍后再试</div>';
                });
        }
        
        // 加载论坛统计
        function loadForumStats() {
            fetch('/api/forum/stats')
                .then(response => response.json())
                .then(stats => {
                    document.getElementById('totalPosts').textContent = stats.totalPosts || 0;
                    document.getElementById('totalUsers').textContent = stats.totalUsers || 0;
                    document.getElementById('todayPosts').textContent = stats.todayPosts || 0;
                })
                .catch(error => {
                    console.error('加载论坛统计失败:', error);
                });
        }
        
        // 加载热门标签
        function loadHotTags() {
            fetch('/api/forum/hot-tags?count=5')
                .then(response => response.json())
                .then(tags => {
                    const tagsList = document.getElementById('hotTagsList');
                    tagsList.innerHTML = '';
                    
                    if (tags && tags.length > 0) {
                        tags.forEach(tag => {
                            const tagElement = document.createElement('div');
                            tagElement.className = 'hot-tag';
                            tagElement.innerHTML = `
                                ${tag.key}
                                <span class="tag-count">${tag.value}</span>
                            `;
                            tagElement.onclick = function() {
                                searchByTag(tag.key);
                            };
                            tagsList.appendChild(tagElement);
                        });
                    } else {
                        tagsList.innerHTML = '<div>暂无热门标签</div>';
                    }
                })
                .catch(error => {
                    console.error('加载热门标签失败:', error);
                    document.getElementById('hotTagsList').innerHTML = '<div>加载热门标签失败</div>';
                });
        }
        
        // 按标签搜索
        function searchByTag(tag) {
            console.log(`搜索标签: ${tag}`);
            
            fetch(`/api/forum/search/tag/${encodeURIComponent(tag)}`)
                .then(response => response.json())
                .then(posts => {
                    isSearchMode = true;
                    
                    // 显示搜索结果区域，隐藏帖子列表和分页
                    document.getElementById('searchResults').style.display = 'block';
                    document.getElementById('postList').style.display = 'none';
                    document.getElementById('pagination').style.display = 'none';
                    document.getElementById('sortOptions').style.display = 'none';
                    
                    // 设置搜索关键词
                    document.getElementById('searchKeyword').textContent = `标签 "${tag}"`;
                    
                    // 清空所有搜索结果区域
                    document.getElementById('titleSearchResults').innerHTML = '';
                    document.getElementById('tagSearchResults').innerHTML = '';
                    document.getElementById('contentSearchResults').innerHTML = '';
                    
                    // 在标签匹配区域显示结果
                    const tagResults = document.getElementById('tagSearchResults');
                    
                    if (posts.length === 0) {
                        tagResults.innerHTML = '<div class="no-results">没有找到包含此标签的帖子</div>';
                        return;
                    }
                    
                    posts.forEach((post, index) => {
                        const date = new Date(post.createdAt);
                        const formattedDate = `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, '0')}-${date.getDate().toString().padStart(2, '0')} ${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')}`;
                        
                        const postItem = document.createElement('div');
                        postItem.className = 'post-item';
                        postItem.style.setProperty('--index', index);
                        
                        postItem.innerHTML = `
                            <div class="post-title"><a href="/forum/post/${post.id}">${post.title}</a></div>
                            <div class="post-meta">
                                <div class="post-author"><i class="fas fa-user"></i> ${post.username || '匿名用户'}</div>
                                <div class="post-date"><i class="far fa-clock"></i> ${formattedDate}</div>
                                <div class="post-views"><i class="fas fa-eye"></i> ${post.viewCount}</div>
                            </div>
                            <div class="post-preview">${post.content}</div>
                            <div class="post-actions">
                                <div class="post-stats">
                                    <div class="post-likes"><i class="far fa-heart"></i> ${post.likeCount}</div>
                                    <div class="post-comments"><i class="far fa-comment"></i> ${post.commentCount}</div>
                                </div>
                            </div>
                        `;
                        
                        tagResults.appendChild(postItem);
                    });
                })
                .catch(error => {
                    console.error('按标签搜索失败:', error);
                    document.getElementById('tagSearchResults').innerHTML = '<div class="no-results">搜索失败，请稍后再试</div>';
                });
        }
        
        // 返回论坛列表
        function backToList() {
            // 清除URL中的参数并重定向到论坛首页
            window.location.href = '/forum';
        }
        
        // 执行高级搜索
        function performSearch() {
            console.log('执行performSearch函数');
            try {
                const searchInput = document.getElementById('searchInput');
                console.log('搜索输入框元素:', searchInput);
                
                if (!searchInput) {
                    console.error('未找到搜索输入框元素');
                    return;
                }
                
                const keyword = searchInput.value.trim();
                console.log('搜索关键词:', keyword);
                
                if (!keyword) {
                    // 替换alert为模态窗提示
                    showSearchAlert('请输入搜索关键词');
                    return;
                }
                
                console.log(`开始执行搜索: ${keyword}`);
                
                fetch(`/api/forum/search?keyword=${encodeURIComponent(keyword)}`)
                    .then(response => {
                        console.log('搜索API响应状态:', response.status);
                        return response.json();
                    })
                    .then(data => {
                        console.log('搜索结果数据:', data);
                        isSearchMode = true;
                        
                        // 显示搜索结果区域，隐藏帖子列表和分页
                        document.getElementById('searchResults').style.display = 'block';
                        document.getElementById('postList').style.display = 'none';
                        document.getElementById('pagination').style.display = 'none';
                        document.getElementById('sortOptions').style.display = 'none';
                        
                        // 设置搜索关键词
                        document.getElementById('searchKeyword').textContent = `"${keyword}"`;
                        
                        // 处理标题匹配结果
                        const titleResults = document.getElementById('titleSearchResults');
                        if (data.titleMatches && data.titleMatches.length > 0) {
                            console.log(`标题匹配结果: ${data.titleMatches.length}个`);
                            titleResults.innerHTML = '';
                            renderSearchResults(data.titleMatches, titleResults, keyword);
                        } else {
                            console.log('没有标题匹配结果');
                            titleResults.innerHTML = '<div class="no-results">没有找到标题匹配的帖子</div>';
                        }
                        
                        // 处理标签匹配结果
                        const tagResults = document.getElementById('tagSearchResults');
                        if (data.tagMatches && data.tagMatches.length > 0) {
                            console.log(`标签匹配结果: ${data.tagMatches.length}个`);
                            tagResults.innerHTML = '';
                            renderSearchResults(data.tagMatches, tagResults, keyword);
                        } else {
                            console.log('没有标签匹配结果');
                            tagResults.innerHTML = '<div class="no-results">没有找到标签匹配的帖子</div>';
                        }
                        
                        // 处理内容匹配结果
                        const contentResults = document.getElementById('contentSearchResults');
                        if (data.contentMatches && data.contentMatches.length > 0) {
                            console.log(`内容匹配结果: ${data.contentMatches.length}个`);
                            contentResults.innerHTML = '';
                            renderSearchResults(data.contentMatches, contentResults, keyword);
                        } else {
                            console.log('没有内容匹配结果');
                            contentResults.innerHTML = '<div class="no-results">没有找到内容匹配的帖子</div>';
                        }
                    })
                    .catch(error => {
                        console.error('搜索失败:', error);
                        // 替换alert为模态窗提示
                        showSearchAlert('搜索失败，请稍后再试');
                    });
            } catch (error) {
                console.error('执行搜索时出错:', error);
                // 替换alert为模态窗提示
                showSearchAlert('搜索出现错误，请稍后再试');
            }
        }
        
        // 渲染搜索结果
        function renderSearchResults(posts, container, keyword) {
            posts.forEach((post, index) => {
                const date = new Date(post.createdAt);
                const formattedDate = `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, '0')}-${date.getDate().toString().padStart(2, '0')} ${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')}`;
                
                // 高亮显示匹配的关键词
                let highlightedTitle = post.title;
                let highlightedContent = post.content;
                
                if (keyword) {
                    const regex = new RegExp(keyword, 'gi');
                    highlightedTitle = highlightedTitle.replace(regex, match => `<span class="search-highlight">${match}</span>`);
                    highlightedContent = highlightedContent.replace(regex, match => `<span class="search-highlight">${match}</span>`);
                }
                
                const postItem = document.createElement('div');
                postItem.className = 'post-item';
                postItem.style.setProperty('--index', index);
                
                postItem.innerHTML = `
                    <div class="post-title"><a href="/forum/post/${post.id}">${highlightedTitle}</a></div>
                    <div class="post-meta">
                        <div class="post-author"><i class="fas fa-user"></i> ${post.username || '匿名用户'}</div>
                        <div class="post-date"><i class="far fa-clock"></i> ${formattedDate}</div>
                        <div class="post-views"><i class="fas fa-eye"></i> ${post.viewCount}</div>
                    </div>
                    <div class="post-preview">${highlightedContent}</div>
                    <div class="post-actions">
                        <div class="post-stats">
                            <div class="post-likes"><i class="far fa-heart"></i> ${post.likeCount}</div>
                            <div class="post-comments"><i class="far fa-comment"></i> ${post.commentCount}</div>
                        </div>
                    </div>
                `;
                
                container.appendChild(postItem);
            });
        }
        
        // 检查用户是否被禁言
        async function checkMuteStatus() {
            try {
                const response = await fetch('/api/check-mute-status');
                
                if (response.status === 403) {
                    // 用户已被禁言
                    const data = await response.json();
                    // 设置禁言信息
                    document.getElementById('muteMessage').textContent = data.detail || '您的账户已被禁言，无法发帖。';
                    document.getElementById('muteReason').textContent = data.reason || '违反平台规则';
                    
                    // 显示禁言模态框
                    document.getElementById('muteModal').style.display = 'flex';
                    return true;
                } else if (response.status === 401) {
                    // 用户未登录
                    showLoginModal();
                    return true;
                } else if (response.ok) {
                    // 用户未被禁言
                    return false;
                } else {
                    console.error('检查禁言状态失败:', response.status);
                    return false;
                }
            } catch (error) {
                console.error('检查禁言状态出错:', error);
                return false;
            }
        }
        
        // 关闭禁言提示模态框
        function closeMuteModal() {
            document.getElementById('muteModal').style.display = 'none';
        }
        
        // 创建新帖子
        async function createPost() {
            if (!isLoggedIn) {
                showLoginModal('请先登录后再发帖');
                return;
            }
            
            // 检查用户是否被禁言
            const isMuted = await checkMuteStatus();
            if (isMuted) {
                return;
            }
            
            window.location.href = '/forum/create';
        }
        
        // 显示登录提示模态框
        function showLoginModal(message) {
            document.getElementById('modalMessage').textContent = message || '请先登录后再进行操作';
            document.getElementById('loginModal').style.display = 'flex';
        }
        
        // 关闭登录提示模态框
        function closeModal() {
            document.getElementById('loginModal').style.display = 'none';
        }
        
        // 跳转到登录页面
        function goToLogin() {
            // 获取当前模态框消息，判断是否为回测相关
            const modalMessage = document.getElementById('modalMessage').textContent;
            if (modalMessage.includes('回测')) {
                window.location.href = '/login?redirect=/backtest';
            } else {
                window.location.href = '/login?redirect=/forum/create';
            }
        }
        
        // 编辑帖子
        function editPost(postId) {
            window.location.href = `/forum/edit/${postId}`;
        }
        
        // 显示举报模态框
        function showReportModal(postId) {
            if (!isLoggedIn) {
                showLoginModal('请先登录后再举报帖子');
                return;
            }
            
            currentPostId = postId;
            document.getElementById('reportModal').style.display = 'flex';
        }
        
        // 关闭举报模态框
        function closeReportModal() {
            document.getElementById('reportModal').style.display = 'none';
            
            // 清空选中的选项和输入内容
            const radioButtons = document.querySelectorAll('input[name="reportReason"]');
            radioButtons.forEach(button => button.checked = false);
            document.getElementById('reportDetail').value = '';
        }
        
        // 提交举报
        function submitReport() {
            const selectedReason = document.querySelector('input[name="reportReason"]:checked');
            if (!selectedReason) {
                showToast('请选择举报原因', 'warning');
                return;
            }
            
            const reason = selectedReason.value;
            const detail = document.getElementById('reportDetail').value.trim();
            
            // 提交举报信息到后端
            fetch('/api/forum/report', {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json'
                },
                body: JSON.stringify({
                    postId: currentPostId,
                    reason: reason,
                    detail: detail
                })
            })
            .then(response => {
                if (response.ok) {
                    alert('举报已提交，感谢您的反馈！');
                    closeReportModal();
                } else {
                    throw new Error('提交举报失败');
                }
            })
            .catch(error => {
                console.error('提交举报失败:', error);
                alert('提交举报失败，请稍后再试');
            });
        }
        
        // 渲染分页
        function renderPagination(pagination) {
            const paginationContainer = document.getElementById('pagination');
            paginationContainer.innerHTML = '';
            
            const totalPages = pagination.totalPages;
            const currentPage = pagination.currentPage;
            
            // 上一页按钮
            const prevItem = document.createElement('div');
            prevItem.className = `page-item ${currentPage === 1 ? 'disabled' : ''}`;
            
            const prevLink = document.createElement('a');
            prevLink.className = 'page-link';
            prevLink.href = 'javascript:void(0)';
            prevLink.innerHTML = '&laquo;';
            if (currentPage > 1) {
                prevLink.addEventListener('click', () => loadPosts(currentPage - 1));
            }
            
            prevItem.appendChild(prevLink);
            paginationContainer.appendChild(prevItem);
            
            // 页码按钮
            const maxPagesToShow = 5;
            let startPage = Math.max(1, currentPage - Math.floor(maxPagesToShow / 2));
            let endPage = Math.min(totalPages, startPage + maxPagesToShow - 1);
            
            if (endPage - startPage + 1 < maxPagesToShow) {
                startPage = Math.max(1, endPage - maxPagesToShow + 1);
            }
            
            for (let i = startPage; i <= endPage; i++) {
                const pageItem = document.createElement('div');
                pageItem.className = `page-item ${i === currentPage ? 'active' : ''}`;
                
                const pageLink = document.createElement('a');
                pageLink.className = 'page-link';
                pageLink.href = 'javascript:void(0)';
                pageLink.textContent = i;
                pageLink.addEventListener('click', () => loadPosts(i));
                
                pageItem.appendChild(pageLink);
                paginationContainer.appendChild(pageItem);
            }
            
            // 下一页按钮
            const nextItem = document.createElement('div');
            nextItem.className = `page-item ${currentPage === totalPages ? 'disabled' : ''}`;
            
            const nextLink = document.createElement('a');
            nextLink.className = 'page-link';
            nextLink.href = 'javascript:void(0)';
            nextLink.innerHTML = '&raquo;';
            if (currentPage < totalPages) {
                nextLink.addEventListener('click', () => loadPosts(currentPage + 1));
            }
            
            nextItem.appendChild(nextLink);
            paginationContainer.appendChild(nextItem);
        }
        
        // 检查登录状态并跳转到回测页面或显示登录提示
        function checkLoginForBacktest() {
            if (isLoggedIn) {
                // 已登录，跳转到回测页面
                window.location.href = '/backtest';
            } else {
                // 未登录，显示登录提示模态框
                showLoginModal('请先登录以使用回测功能');
            }
        }

        // 关闭搜索提示模态框
        function closeSearchAlertModal() {
            document.getElementById('searchAlertModal').style.display = 'none';
        }
        
        // 显示搜索提示模态框
        function showSearchAlert(message) {
            document.getElementById('searchAlertMessage').textContent = message || '请输入搜索关键词';
            document.getElementById('searchAlertModal').style.display = 'flex';
        }
    </script>
    
    <!-- 免责声明和版权信息 -->
    <div class="disclaimer-container">
        <div class="disclaimer-text">
            <strong>免责声明：</strong>本论坛内容由用户发布，不代表FinData平台立场。用户应对自己发表的内容负责，遵守相关法律法规。
            发布内容前请慎重考虑，任何发布的言论、图片一经发布将无法删除，平台有权根据相关规定对内容进行管理。
            请勿发布违法、虚假、误导性金融信息，不得利用本平台从事非法活动。
        </div>
        <div class="copyright">
            © 2023-2024 FinData. All Rights Reserved. 保留所有权利。
        </div>
    </div>
</body>
</html>
